#ifndef LOGGER_H
#define LOGGER_H

#include <QFile>
#include <QMutex>

class Logger
{
public:
    static Logger &instance()
    {
        static Logger logger;
        return logger;
    }

    bool setLogFile(const QString &filePath);

    static void log(QtMsgType type, const QMessageLogContext &context, const QString &msg);

private:
    QFile *file = nullptr;
    QMutex mutex;

    Logger();
    ~Logger();

    Logger(const Logger &) = delete;
    const Logger &operator=(const Logger &) = delete;
};

static inline bool Logger_setLogFile(const QString &filePath)
{
    return Logger::instance().setLogFile(filePath);
}

#endif // LOGGER_H
